package com.example.computer_exam_training_sys.entity;

import lombok.Data;
import java.time.LocalDateTime;

@Data
public class UserStudyNotes {
    private Long noteId;           // 笔记ID
    private Long userId;           // 用户ID
    private Long questionId;       // 题目ID
    private String content;        // 笔记内容
    private String tags;           // 标签，多个标签用逗号分隔
    private Boolean isPublic;      // 是否公开
    private Boolean isShared;      // 是否已分享
    private Integer viewCount;     // 浏览次数
    private Integer likeCount;     // 点赞次数
    private Integer commentCount;  // 评论次数
    private LocalDateTime createTime; // 创建时间
    private LocalDateTime updateTime; // 更新时间
    private String lastUpdateUser; // 最后更新人
    private Boolean isDeleted;
    private LocalDateTime deleteTime;
    
    // 非数据库字段，用于关联查询
    private String userName;       // 用户名
    private String questionTitle;  // 题目标题
    
    // 内容验证常量
    public static final int MAX_CONTENT_LENGTH = 10000;
    public static final int MAX_TAG_LENGTH = 50;
    public static final int MAX_TAGS_COUNT = 10;
    
    // 内容验证方法
    public boolean validateContent() {
        return content != null && content.length() <= MAX_CONTENT_LENGTH;
    }
    
    // 标签验证方法
    public boolean validateTags() {
        if (tags == null || tags.isEmpty()) {
            return true;
        }
        String[] tagArray = tags.split(",");
        if (tagArray.length > MAX_TAGS_COUNT) {
            return false;
        }
        for (String tag : tagArray) {
            if (tag.trim().length() > MAX_TAG_LENGTH) {
                return false;
            }
        }
        return true;
    }
} 